<template>
  <div v-if="isTrue">
    <el-form
      :model="form"
      ref="form"
      label-width="144px"
      class="ccui-form"
      :rules="rules"
    >
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="填报单位：" prop="reportInOrgId">
            <el-select
              v-model="form.reportInOrgId"
              placeholder="请选择填报单位"
              @change="changeReportInOrgId"
            >
              <el-option
                v-for="item in reportOptions"
                :key="item.orgId"
                :label="item.name"
                :value="item.orgId"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="合同签订单位(甲方)：" prop="partyAName">
            <el-input v-model="form.partyAName" disabled />
            <el-button
              plain
              type="single-number"
              @click="$refs.choosePartyA.showDialogInventory()"
            >
              选择
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
      <!--项目名称、争议解决方案-->
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="项目名称：" prop="projectName">
            <el-input v-model="form.projectName" disabled />
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handleShowProjectNameDialog"
              >选择</el-button
            >
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handleProjectName"
              >清空</el-button
            >
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="争议解决方案：" prop="disputeResolutionCode">
            <el-select
              v-model="form.disputeResolutionName"
              placeholder="请选择争议解决方案"
              @change="changeDisputeResolutionCode(form.disputeResolutionName)"
            >
              <el-option
                v-for="item in disputeResolutionOptions"
                :key="item.code"
                :label="item.name"
                :value="item.name"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="供应商1：" prop="partyBName">
            <el-input v-model="form.partyBName" disabled />
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handleShowPartyBDialog"
              >选择</el-button
            >
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handlePartyBName"
              >清空</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="供应商2：" prop="partyBNameBak">
            <el-input v-model="form.partyBNameBak" disabled />
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handleShowPartyBBakDialog"
              >选择</el-button
            >
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handlePartyBNameBak"
              >清空</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="合同编号：" prop="contractCode">
            <el-input v-model="form.contractCode" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="合同名称：" prop="contractName">
            <el-input
              v-model="form.contractName"
              placeholder="请输入合同名称"
              maxlength="300"
              @blur="handleTrim('contractName')"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="协议编号：" prop="protocalCode">
            <el-input v-model="form.protocalCode" disabled />
            <!-- 协议编号 -->
            <dialogMultiSelectTable
              dialogTitle="框架协议参照选择"
              errorMessage="请先选择供应商 1"
              :isShow="isMultiShow"
              :searchInputArr="jsList.agreementSearchInputArr"
              :tableHeadOptions="jsList.agreementTableHeadOptions"
              :getTableList="listProtocolinfoPage"
              :optionalParams="optionalParams"
              :selectTableList="[]"
              @confirm="confirmSelect"
            />
            <el-button
              plain
              type="single-number"
              style="margin-left: 10px"
              @click="handleProtocalCode"
              >清空</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否海外运输：" prop="isOverseas">
            <el-select
              v-model="form.isOverseas"
              placeholder="请选择"
              :disabled="!!form.protocalCode"
              @change="isOverseasChange"
            >
              <el-option
                v-for="item in jsList.isOverseasList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
                :disabled="item.value === -1"
              >
                <span v-if="item.isLeaf" :class="{ optionLeaf: item.isLeaf }"
                  >├ {{ item.label }}</span
                >
                <span v-else>{{ item.label }}</span>
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item
            v-if="
              form.isOverseas !== 3 &&
              !['人民币', '美元'].includes(form.currencyName)
            "
            label="兑美元汇率："
            prop="usExchangeRate"
            key="usExchangeRate"
          >
            <el-input
              v-model="form.usExchangeRate"
              placeholder="请输入兑美元汇率"
              maxlength="30"
              @blur="handleCurrencyChange('usExchangeRate')"
            />
          </el-form-item>
          <el-form-item v-else />
        </el-col>

        <el-col :span="12">
          <el-form-item label="币种：" prop="currencyName">
            <el-select
              v-model="form.currencyName"
              :disabled="!!form.protocalCode"
              placeholder="请选择币种"
              filterable
              @change="handleChange('currency')"
            >
              <el-option
                v-for="item in Enum.currencyList"
                :key="item.dicKey"
                :label="item.dicValue"
                :value="item.dicValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10" v-if="form.currencyName !== '人民币'">
        <el-col :span="12">
          <el-form-item
            label="兑人民币汇率："
            prop="chExchangeRate"
            key="chExchangeRate"
          >
            <el-input
              v-model="form.chExchangeRate"
              placeholder="请输入兑人民币汇率"
              maxlength="30"
              @blur="handleCurrencyChange('chExchangeRate')"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item
            label="合同金额(含税)："
            prop="initTotalContractPriceIncludeTax"
          >
            <el-input
              v-model="form.initTotalContractPriceIncludeTax"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="合同金额(不含税)："
            prop="initTotalConractPriceExcludeTax"
          >
            <el-input v-model="form.initTotalConractPriceExcludeTax" disabled />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="是否浮动合同价格：" prop="isFloatContractPrice">
            <el-radio-group v-model="form.isFloatContractPrice">
              <el-radio
                v-for="item in jsList.whetherList"
                :key="item.dicKey"
                :label="item.dicKey"
                >{{ item.dicValue }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="编制人：" prop="compileUser">{{
            form.compileUser
          }}</el-form-item>
        </el-col>
      </el-row>

      <!--发票类型、合同范本使用情况-->
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="发票类型：" prop="invoiceCode">
            <el-select
              v-model="form.invoiceName"
              placeholder="请选择发票类型"
              @change="changeInvoiceCode(form.invoiceName)"
            >
              <el-option
                v-for="item in Enum.invoiceList"
                :key="item.dicKey"
                :label="item.dicValue"
                :value="item.dicValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item
            label="合同范本使用情况："
            prop="useOfModelContractCode"
          >
            <el-select
              v-model="form.useOfModelContractName"
              placeholder="请选择合同范本使用情况"
              @change="
                changeUseOfModelContractCode(form.useOfModelContractName)
              "
            >
              <el-option
                v-for="item in useOfModelContractOptions"
                :key="item.code"
                :label="item.name"
                :value="item.name"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="多税率：" prop="multiRateCode">
            <el-radio-group
              v-model="form.multiRateCode"
              @change="multiRateCodeChange"
            >
              <el-radio
                v-for="item in jsList.whetherList"
                :key="item.dicKey"
                :label="item.dicKey"
                >{{ item.dicValue }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            v-if="form.multiRateCode === 1"
            label="税率："
            prop="taxRatePercent"
            key="taxRatePercent"
          >
            <el-select
              v-model="form.taxRatePercent"
              placeholder="请选择税率"
              @change="handleChange('taxRatePercent')"
            >
              <el-option
                v-for="item in Enum.taxRateCodeList"
                :key="item.dicKey"
                :label="item.dicValue"
                :value="item.dicValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item v-else />
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="对方联系人：" prop="contractPerson">
            <el-input
              v-model="form.contractPerson"
              placeholder="请输入对方联系人"
              maxlength="20"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="运输产品类别：" prop="transportCategoryCode">
            <el-select
              v-model="form.transportCategoryCode"
              placeholder="请选择运输产品类别"
              filterable
              @change="handleChange('transportCategoryCode')"
            >
              <el-option
                v-for="item in jsList.transportCategory"
                :key="item.dicKey"
                :label="item.dicValue"
                :value="item.dicKey"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item
            label="对方联系手机号："
            :prop="
              form.isOverseas === 3
                ? 'contractPersonTel'
                : 'contractPersonTelOverSea'
            "
          >
            <el-input
              v-model="form.contractPersonTel"
              maxlength="15"
              placeholder="请输入对方联系手机号"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="编制日期：" prop="compileDate">
            <!-- <el-date-picker
              v-model="form.compileDate"
              type="date"
              placeholder="请选择编制日期"
              value-format="yyyy-MM-dd"
              :clearable="false"
              disabled
            /> -->
            <el-input v-model="form.compileDate" disabled />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10" v-if="form.isFloatContractPrice === 0">
        <el-col :span="18">
          <el-form-item label="浮动价说明：" prop="floatDesc">
            <el-input
              type="textarea"
              :rows="5"
              maxlength="500"
              show-word-limit
              placeholder="请输入浮动价说明"
              v-model="form.floatDesc"
            >
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="18">
          <el-form-item label="合同主要条款：" prop="mainTermsOfContract">
            <el-input
              type="textarea"
              :rows="5"
              maxlength="500"
              show-word-limit
              placeholder="请输入合同主要条款"
              v-model="form.mainTermsOfContract"
            >
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="18">
          <el-form-item label="备注：" prop="remark">
            <el-input
              type="textarea"
              :rows="5"
              maxlength="500"
              show-word-limit
              placeholder="请输入备注"
              v-model="form.remark"
            >
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- 甲方选择 -->
    <choosePartyA
      ref="choosePartyA"
      btnText="选择"
      selectedTitle="已选择单位"
      title="请选择单位"
      mode="radio"
      :showBtnTest="false"
      :isselectedData="partyASelectedNode"
      :requestTreeFunction="getQryTree"
      :requestSeachFunction="queryMemberGroup"
      @selectedStaffSuccess="selectPartyA"
    />

    <!-- 供应商1 -->
    <chooseSupplier
      ref="partyBVisibleDialog"
      :supplierData="supplierObj1"
      @selectPartyB="selectPartyB"
    />

    <!-- 供应商2 -->
    <chooseSupplier
      ref="partyBNameBakVisibleDialog"
      :supplierData="supplierObj2"
      @selectPartyB="selectPartyBNameBak"
    />

    <!-- 项目名称 -->
    <chooseSupplier
      ref="projectNameBakVisibleDialog"
      :supplierData="projectObj"
      @selectPartyB="selectProjectName"
    />
  </div>
</template>

<script>
import { mapActions, mapGetters, mapState } from "vuex";
import publicComponent from "@/basa/components/public";
import { dateFormat1, proxyDateFormat } from "@/basa/utils";
import { showLoading } from "@/basa/utils/public";
import { listProtocolinfoPage } from "../api";
import {
  getUserInfoA,
  getSupplierData,
  getReportInOrgData,
  queryMemberGroup,
  getQryTree,
  postGetEnum,
  qrySupplierType,
  qryProjectDataAll
} from "@/basa/api";
import validators from "@/basa/utils/validators";
import jsList from "../js";
export default {
  name: "baseInfo",
  props: {
    detail: {
      type: Object,
      default: () => {}
    }
  },
  components: {
    dialogMultiSelectTable: publicComponent.dialogMultiSelectTable,
    chooseSupplier: publicComponent.singleSupplier,
    choosePartyA: publicComponent.staffSelector
  },
  data() {
    return {
      jsList,
      isTrue: false,
      Enum: {
        currencyList: [], // 币种
        taxRateCodeList: [], // 税率
        invoiceList: [] // 发票
      },
      smpProjectReqBO: {},
      form: {
        reportInOrgId: "", // 填报单位id
        reportInOrgName: "", // 填报单位名称
        projectCode: "", // 项目名称编码
        projectName: "", // 项目名称
        disputeResolutionCode: "", //争议解决方式编码
        disputeResolutionName: "", //争议解决方式名称
        invoiceCode: "", // 发票类型编码
        invoiceName: "", // 发票类型名称
        useOfModelContractCode: "", // 合同范本编码
        useOfModelContractName: "", // 合同范本名称
        partyAName: "", // 合同签订单位(甲方)
        partyAId: " ", // 合同签订单位id
        partyBName: "", // 供应商1
        companyOrgId: "", // 供应商1
        partyBNameBak: "", // 供应商2
        companyOrgIdBak: "", // 供应商2
        contractCode: "", // 合同编号
        contractName: "", // 合同名称
        protocalCode: "", // 协议编号
        protocalId: "", // 协议编号
        protocalName: "", // 协议编号
        currencyName: "人民币", // 币种
        currencyCode: "1", // 币种
        chExchangeRate: "", // 兑人民币汇率
        exchangeRateRefDate: "", // 汇率参照日期
        initTotalContractPriceIncludeTax: "", // 合同金额(含税)元
        initTotalConractPriceExcludeTax: "", // 合同金额(不含税)元
        isFloatContractPrice: 0, // 是否浮动合同价格
        isOverseas: 3, // 是否海外采购
        taxRatePercent: "", // 税率
        multiRateCode: 1, // 多税率
        contractPerson: "", // 对方联系人
        transportCategoryCode: "01", // 运输产品类别
        transportCategoryName: "钢材", // 运输产品类别
        contractPersonTel: "", // 对方联系手机号
        compileDate: "", // 编制日期
        compileUser: "", // 编制人
        usExchangeRate: "", // 兑美元汇率
        floatDesc: "", // 浮动价说明
        mainTermsOfContract: "", // 合同主要条款
        remark: "", // 备注
        suppDomesticTradeType: "", //供应商1是否内贸标志位
        suppSubDomesticTradeType: "", //供应商2是否内贸标志位
        isShow: 0,
        supplierARankName: "",
        supplierARankType: "",
        supplierABakRankName: "",
        supplierABakRankType: ""
      },
      rules: {
        reportInOrgId: [
          { required: true, message: "请输入填报单位", trigger: "blur" }
        ],
        partyAName: [
          {
            required: true,
            message: "请输入合同签订单位(甲方)",
            trigger: "blur"
          }
        ],
        projectName: [
          { required: true, message: "请选择项目名称", trigger: "change" }
        ],
        disputeResolutionCode: [
          { required: true, message: "请选择争议解决方案", trigger: "blur" }
        ],
        partyBName: [
          { required: true, message: "请选择供应商1", trigger: "change" }
        ],
        taxRatePercent: [
          { required: true, message: "请选择税率", trigger: "change" }
        ],
        contractName: [
          { required: true, message: "请输入合同名称", trigger: "blur" }
        ],
        currencyName: [
          { required: true, message: "请选择币种", trigger: "change" }
        ],
        chExchangeRate: [
          { required: true, message: "请输入兑人民币汇率", trigger: "blur" },
          {
            pattern: /(^(\d{0,21})\.(\d{0,4})$)|(^\d{0,26}$)/,
            message: "请输入正确的税率",
            trigger: "blur"
          }
        ],
        isFloatContractPrice: [
          {
            required: true,
            message: "请选择是否浮动合同价格",
            trigger: "change"
          }
        ],
        isOverseas: [
          { required: true, message: "请选择是否海外运输", trigger: "change" }
        ],
        taxRateCode: [
          { required: true, message: "请选择税率", trigger: "change" }
        ],
        invoiceCode: [
          { required: true, message: "请选择发票类型", trigger: "blur" }
        ],
        useOfModelContractCode: [
          {
            required: true,
            message: "请选择合同范本使用情况",
            trigger: "blur"
          }
        ],
        multiRateCode: [
          { required: true, message: "请输入多税率", trigger: "blur" }
        ],
        contractPerson: [
          { required: true, message: "请输入对方联系人", trigger: "blur" }
        ],
        transportCategoryCode: [
          { required: true, message: "请输入运输产品类别", trigger: "change" }
        ],
        contractPersonTel: [
          {
            required: true,
            message: "请输入对方联系手机号",
            trigger: "blur"
          },
          {
            validator: validators.userMobile,
            message: "请输入正确的手机号",
            trigger: "blur"
          }
        ],
        contractPersonTelOverSea: [
          {
            max: 15,
            trigger: "blur"
          }
        ],
        floatDesc: [
          { required: true, message: "请输入浮动价说明", trigger: "blur" }
        ],
        usExchangeRate: [
          { required: true, message: "请输入兑美元汇率", trigger: "blur" },
          {
            pattern: /(^(\d{0,21})\.(\d{0,4})$)|(^\d{0,26}$)/,
            message: "请输入正确的税率",
            trigger: "blur"
          }
        ],
        compileUser: [
          {
            required: true,
            trigger: "blur"
          }
        ],
        compileDate: [
          {
            required: true,
            trigger: "blur"
          }
        ]
      },
      reportOptions: [], // 填报单位
      projectOptions: [], // 项目名称
      invoiceOptions: [], // 发票类型
      disputeResolutionOptions: [
        { code: "01", name: "诉讼" },
        { code: "02", name: "仲裁" },
        { code: "03", name: "内部调解" },
        { code: "04", name: "协商" },
        { code: "99", name: "其他" }
      ], // 争议解决方案
      useOfModelContractOptions: [
        { code: "01", name: "使用国家、行业范本" },
        { code: "02", name: "使用本单位范本" },
        { code: "03", name: "使用对方范本" },
        { code: "99", name: "未使用范本" }
      ], // 合同范本使用情况
      supplierObj1: {
        title: "供应商查询",
        tableHeadOptions: jsList.supplierTableHead,
        tableData: [],
        recordsTotal: 0,
        formDate: {
          mainType: "B",
          orgid: "",
          pageNo: 1,
          pageSize: 10
        }
      },
      supplierObj2: {
        title: "供应商查询",
        tableHeadOptions: jsList.supplierTableHead,
        tableData: [],
        recordsTotal: 0,
        formDate: {
          mainType: "B",
          orgid: "",
          pageNo: 1,
          pageSize: 10
        }
      },
      projectObj: {
        title: "项目名称查询",
        tableHeadOptions: jsList.projectTableHead,
        tableData: [],
        recordsTotal: 0,
        formDate: {
          fillOrg: "",
          contractOrderOrg: "",
          pageNo: 1,
          pageSize: 10
        }
      },
      userOpenId: "",
      afterVal: 0,
      optionalParams: {},
      agreementSelectTableList: [],
      supCode: {
        confirmSelect: {
          supplierName: "",
          supplierCode: "",
          companyOrgId: ""
        },
        status: "reset"
      }, //供应商1信息
      isMultiShow: false,
      partyASelectedNode: [],
      tempIsOverseas: null,
      initCurrencyCode: null,
      initCurrencyName: null,
      initProtocalCode: null,
      initProtocalId: null,
      initProtocalName: null,
      beforeIsOverseas: "",
      beforeCurrencyCode: "",
      beforeCurrencyName: "",
      beforeProtocalCode: "",
      beforeProtocalId: "",
      beforeProtocalName: "",
      formLoading: null
    };
  },
  created() {
    this.init();

    this.$bus.$on("setPriceSum", val => {
      this.form.initTotalContractPriceIncludeTax = Number(
        val.setContractPriceIncludeTax
      ).toFixed(2);
      this.form.initTotalConractPriceExcludeTax = Number(
        val.setContractPriceExcludeTax
      ).toFixed(2);
    });

    this.$once("hook:beforeDestroy", () => {
      this.$bus.$off("setPriceSum");
    });
  },
  methods: {
    init() {
      this.getUserInfo();
      this.postGetEnum();
      const { state, smpPcConc, pcFinance } = this.detail;
      if (state === "edit") {
        this.form = {
          ...smpPcConc,
          chExchangeRate: smpPcConc.chExchangeRate
            ? Number(smpPcConc.chExchangeRate).toFixed(4)
            : "",
          usExchangeRate: smpPcConc.usExchangeRate
            ? Number(smpPcConc.usExchangeRate).toFixed(4)
            : "",
          exchangeRateRefDate: smpPcConc.exchangeRateRefDate
            ? proxyDateFormat(smpPcConc.exchangeRateRefDate)
            : "",
          signDate: smpPcConc.signDate
            ? proxyDateFormat(smpPcConc.signDate)
            : "",
          createTime: smpPcConc.createTime
            ? proxyDateFormat(smpPcConc.createTime)
            : "",
          compileDate: smpPcConc.compileDate
            ? proxyDateFormat(smpPcConc.compileDate)
            : "",
          transportCategoryCode: smpPcConc.transportCategoryCode
            ? String(smpPcConc.transportCategoryCode)
            : "01",
          materialSourceCode: pcFinance.length
            ? pcFinance[0].materialSourceCode
            : "",
          contractPerson: pcFinance.length ? pcFinance[0].contractPerson : "",
          contractPersonTel: pcFinance.length
            ? pcFinance[0].contractPersonTel
            : "",
          multiRateCode: smpPcConc.multiRateCode ?? 1
        };
        const { orgId, partyAName, partyAId } = this.detail.smpPcConc;
        this.getSupplierData(orgId);
        this.supplierObj1.formDate.orgid = orgId;
        this.supplierObj2.formDate.orgid = orgId;
        this.projectObj.formDate.fillOrg = orgId;
        this.projectObj.formDate.contractOrderOrg = partyAId;
        this.optionalParams = {
          ...this.optionalParams,
          reportInOrgId: orgId,
          supCode: this.form.partyBId || "",
          supName: this.form.partyBName || ""
        };
        this.isMultiShow = !!this.form.partyBName;
        this.partyASelectedNode = [{ orgId: partyAId, name: partyAName }]; // 回显签订单位
      } else {
        this.form.compileDate = dateFormat1(new Date());
        // 范本使用默认本单位
        this.form.useOfModelContractCode = "02";
        this.form.useOfModelContractName = "使用本单位范本";
        // 争议解决方案默认仲裁
        this.form.disputeResolutionCode = "02";
        this.form.disputeResolutionName = "仲裁";
      }
    },

    // 供应商 1 显示
    handleShowPartyBDialog() {
      this.$refs.partyBVisibleDialog.visible = true;
      this.getSupplierData(this.form.orgId, this.supplierObj1.formDate);
    },

    // 供应商 2 显示
    handleShowPartyBBakDialog() {
      this.$refs.partyBNameBakVisibleDialog.visible = true;
      this.getSupplierData(this.form.orgId, this.supplierObj2.formDate);
    },

    // 项目名称显示
    handleShowProjectNameDialog() {
      this.$refs.projectNameBakVisibleDialog.visible = true;
      this.getProjectNameData(
        this.form.orgId,
        this.form.partyAId,
        this.projectObj.formDate
      );
    },

    //取消供应商1
    handlePartyBName() {
      this.form.partyBName = "";
      this.form.partyBId = null;
      this.form.suppDomesticTradeType = "";
      this.form.contractPersonTel = "";
      this.form.contractPerson = "";
      this.isMultiShow = false;
      this.selectPartyB(this.supCode);
      this.setShowDoubleTable(false);
      this.setRemoveSupplier(true);

      // 设置清单列表中的采购计划选择状态
      this.setAgreementSelectStatus(false);
      this.setRemoveInventoryList(true);
    },
    //取消供应商2
    handlePartyBNameBak() {
      this.form.partyBNameBak = "";
      this.form.partyBIdBak = null;
      this.form.suppSubDomesticTradeType = "";
      this.setRemoveSupplierB(true);
    },
    // 取消项目名称
    handleProjectName() {
      this.form.projectName = ""; // 项目名称
      this.form.projectCode = null; // 项目编码
      this.smpProjectReqBO = {};
    },
    // 取消协议编码
    handleProtocalCode() {
      this.form.protocalCode = "";
      this.form.protocalId = "";
      this.form.protocalName = "";

      // 清空清单的协议
      this.setDelectList(true);

      // 设置清单列表中的采购计划选择状态
      this.setAgreementSelectStatus(false);
    },

    // 获取枚举
    async postGetEnum() {
      const arr = [
        "getCurrencyTypeDict", // 查询币种字典数据
        "getTaxRateDict", // 查询税率字典数据
        "getReceiptTypeDict" // 查询发票类型
      ];
      for (let i = 0; i < arr.length; i++) {
        const { data } = (await postGetEnum(arr[i])).data;
        this.Enum[Object.keys(this.Enum)[i]] = data;
        // postGetEnum(element).then(res => {
        //   this.Enum[Object.keys(this.Enum)[i]] = res.data.data;
        // });
      }
    },

    handleChange(type) {
      // if (this.form.protocalCode && type === "currency") {
      //   this.form.currencyName = this.beforeCurrencyName;
      //   return this.$showErrorMessage("已经引用协议编号，不允许改变币种");
      // }

      let val = this.form[type === "currency" ? `${type}Name` : type];

      // 处理税率
      if (type === "taxRatePercent") {
        const obj = this.Enum.taxRateCodeList.find(_ => _.dicValue === val);
        this.form.taxRateCode = obj.dicKey;
        if (val !== "免税") {
          const newVal = val.match(/\d+(.\d+)?/g)[0];
          this.form.taxRate = newVal;
          this.afterVal = Number(newVal) / 100;
        } else {
          this.form.taxRate = Number(obj.dicKey);
          this.afterVal = Number(obj.dicKey);
        }
        this.setTaxRate(this.afterVal);
        this.setTaxRateObj(obj);
      } else if (type === "transportCategoryCode") {
        this.form.transportCategoryName = jsList.transportCategory.find(
          _ => _.dicKey === val
        ).dicValue;
      } else {
        this.form[`${type}Code`] = this.Enum[`${type}List`].find(
          _ => _.dicValue === val
        ).dicKey;
      }

      this.$refs["form"].clearValidate(["chExchangeRate"]);

      if (type === "currency") {
        this.setCurrencyObj({
          code: this.form[`${type}Code`],
          name: val
        });

        // 协议添加币种参数
        // this.optionalParams = {
        //   ...this.optionalParams,
        //   currencyCode: this.form[`${type}Code`]
        // };
      }
    },

    getUserInfo() {
      getUserInfoA().then(res => {
        if (this.detail.state === "create") {
          this.form.compileUser = res.data.data.userInfo.name;
          this.form.compileUserId = res.data.data.userInfo.id;
        } else {
          this.form.compileUser = this.detail.smpPcConc.compileUser;
        }
        this.userOpenId = res.data.data.userInfo.openId;
        this.getReportInOrgData(this.userOpenId);
      });
    },

    // 合同签订单位(甲方)
    selectPartyA([data], orgTypes, orginName, node) {
      this.partyASelectedNode = [data];
      this.form.partyAName = data.name;
      this.form.partyAId = data.orgId;
      this.projectObj.formDate.contractOrderOrg = data.orgId;
      this.handleProjectName();
    },

    // 填报信息
    getReportInOrgData(openId) {
      this.formLoading = showLoading();
      getReportInOrgData({ openIds: [openId] }).then(res => {
        this.reportOptions = res.data.data[this.userOpenId];
        const tempObj = this.reportOptions[0]; // 记得改回 [0]
        if (this.detail.state === "create") {
          this.form.partyAName = tempObj.name;
          this.form.partyAId = tempObj.orgId;
          this.form.orgId = tempObj.orgId;
          this.form.reportInOrgName = tempObj.name;
          this.form.reportInOrgId = tempObj.orgId;
          this.supplierObj1.formDate.orgid = tempObj.orgId;
          this.supplierObj2.formDate.orgid = tempObj.orgId;
          this.projectObj.formDate.fillOrg = tempObj.orgId;
          this.projectObj.formDate.contractOrderOrg = tempObj.partyAId;
          this.optionalParams = {
            ...this.optionalParams,
            reportInOrgId: tempObj.orgId
          };
          // 回显签订单位
          this.partyASelectedNode = [
            { orgId: tempObj.orgId, name: tempObj.name }
          ];
          this.getSupplierData(tempObj.orgId);
          this.setRangeList(tempObj);
          this.setOrgId(tempObj.orgId);
        }
        this.$nextTick(() => {
          this.isTrue = true;
          this.formLoading.close();
        });
      });
    },

    // 填报单位
    changeReportInOrgId(val) {
      const tempObj = this.reportOptions.find(e => e.orgId === val);
      this.form.partyBName = "";
      this.form.partyBId = null;
      this.form.suppDomesticTradeType = "";
      this.form.partyBNameBak = "";
      this.form.partyBIdBak = null;
      this.form.suppSubDomesticTradeType = "";
      this.form.contractPerson = "";
      this.form.contractPersonTel = "";
      this.form.projectName = "";
      this.form.projectCode = null;
      this.smpProjectReqBO = {};
      this.optionalParams = {
        ...this.optionalParams,
        supCode: ""
      };
      this.setOrgIdParams(tempObj);
      // this.handleProtocalCode();
      this.setRemoveInventoryList(true);
      this.setRemoveSupplier(true);
      this.setAgreementSelectStatus(false);
      this.setSupplierData(this.supCode);
    },

    // 争议解决方案
    changeDisputeResolutionCode(name) {
      this.form.disputeResolutionCode = this.disputeResolutionOptions.find(
        _ => _.name === name
      ).code;
    },

    // 发票类型
    changeInvoiceCode(val) {
      this.form.invoiceCode = this.Enum.invoiceList.find(
        _ => _.dicValue === val
      ).dicKey;
    },

    // 合同使用范本
    changeUseOfModelContractCode(name) {
      this.form.useOfModelContractCode = this.useOfModelContractOptions.find(
        _ => _.name === name
      ).code;
    },

    setOrgIdParams({ name, orgId, orgFullName }) {
      this.form.orgId = orgId;
      this.form.reportInOrgName = name;
      this.form.reportInOrgId = orgId;
      this.supplierObj1.formDate.orgid = orgId;
      this.supplierObj2.formDate.orgid = orgId;
      this.projectObj.formDate.fillOrg = orgId;
      this.optionalParams = {
        ...this.optionalParams,
        reportInOrgId: orgId
      };
      this.setOrgId(orgId);
      this.setRangeList({ name, orgId, orgFullName });
    },

    // 获取供应商数据
    getSupplierData(orgid, defaultParams = this.supplierObj2.formDate) {
      const data = Object.assign(defaultParams, { orgid });
      getSupplierData(data).then(res => {
        const tableData = res.data.data.rows.map(n => ({
          ...n,
          regNum: n.unifiedCode ? "" : n.regNum
        }));
        this.supplierObj1.tableData = tableData;
        this.supplierObj1.recordsTotal = res.data.data.recordsTotal;
        this.supplierObj2.tableData = tableData;
        this.supplierObj2.recordsTotal = res.data.data.recordsTotal;
      });
    },

    // 供应商设置 start

    // 供应商1
    async selectPartyB(val) {
      if (val.status === "confirm") {
        const {
          confirmSelect,
          confirmSelect: { supplierName, supplierCode, companyOrgId, isInIndy }
        } = val;

        console.log("选择供应商1", val);

        const str = this.getType(confirmSelect);
        if (str === "Object") {
          if (supplierName === this.form.partyBNameBak) {
            this.$showErrorMessage("供应商 1 不能与供应商 2 相同");
            return this.selectPartyBReset(val, 1);
          }

          // 关联关系条件
          if (this.form.partyBName) {
            try {
              const { isClear } = await this.qrySupplierType(supplierName);
              if (!isClear) {
                // 清空协议和清单
                this.form.protocalCode = "";
                this.form.protocalId = "";
                this.form.protocalName = "";
                this.setRemoveInventoryList(true);
              }
            } catch (error) {
              this.$showErrorMessage(error);
            }
          }

          this.isMultiShow = true; // 协议是否可选择
          this.form.partyBName = supplierName;
          this.form.partyBId = supplierCode;
          this.form.suppDomesticTradeType = isInIndy;
          this.form.companyOrgId = companyOrgId;
          this.form.contractPersonTel = confirmSelect.contactMobile;
          this.form.contractPerson = confirmSelect.contactName;
          this.form.supplierARankName = confirmSelect.rankName;
          this.form.supplierARankType = confirmSelect.rankType;

          // 协议请求参数
          this.optionalParams = {
            ...this.optionalParams,
            supCode: supplierCode,
            supName: supplierName
          };
          // set 供应商数据
          this.resetSupplierParams("supplierObj1");
          this.setSupplierData(confirmSelect);
          this.setShowDoubleTable(true);
        }
        // 确认后重置搜索
        this.selectPartyBReset(val, 1);
      } else {
        // this[this.getSelectPartyBStrategy.get(val.status)](val, 1);
        this[this.getSelectPartyBStrategy[val.status]](val, 1);
        if (["closeReset"].includes(val.status)) return; // 点击叉号只清空数据，不调接口
        this.getSupplierData(
          this.form.reportInOrgId,
          this.supplierObj1.formDate
        );
      }
    },

    // 供应商2
    selectPartyBNameBak(val) {
      if (val.status === "confirm") {
        const {
          confirmSelect,
          confirmSelect: { supplierName, supplierCode, companyOrgId, isInIndy }
        } = val;

        console.log("选择供应商2", val);

        const str = this.getType(confirmSelect);
        if (str === "Object") {
          if (this.form.partyBName === supplierName) {
            this.$showErrorMessage("供应商 2 不能与供应商 1 相同");
            return this.selectPartyBReset(val, 2);
          }
          this.resetSupplierParams("supplierObj2");
          this.form.partyBNameBak = supplierName;
          this.form.partyBIdBak = supplierCode;
          this.form.suppSubDomesticTradeType = isInIndy;
          this.form.companyOrgIdBak = companyOrgId;
          this.form.supplierABakRankName = confirmSelect.rankName;
          this.form.supplierABakRankType = confirmSelect.rankType;

          this.setSupplierBData(confirmSelect);
        }
        this.selectPartyBReset(val, 2);
      } else {
        this[this.getSelectPartyBStrategy[val.status]](val, 2);
        if (["closeReset"].includes(val.status)) return; // 点击叉号只清空数据，不调接口
        this.getSupplierData(
          this.form.reportInOrgId,
          this.supplierObj2.formDate
        );
      }
    },

    // 查询供应商关联关系
    qrySupplierType(switchSupplierName) {
      return new Promise(async (resolve, reject) => {
        const obj = {
          supplierName: this.form.partyBName,
          switchSupplierName
        };
        const { data } = await qrySupplierType(obj);
        if (data.code === "0") {
          resolve(data.data);
        } else {
          reject(data.message);
        }
      });
    },

    // 查询
    selectPartyBSearch(val, num) {
      this[`supplierObj${num}`].formDate = val.formDate;
      this[`supplierObj${num}`].formDate.pageNo = 1;
    },

    // 当前页条数
    selectPartyBPageSize(val, num) {
      this[`supplierObj${num}`].formDate.pageSize = val.pageSize;
    },

    // 页码
    selectPartyBPageNo(val, num) {
      this[`supplierObj${num}`].formDate.pageNo = val.pageNo;
    },

    // 重置
    selectPartyBReset(val, num) {
      this[`supplierObj${num}`].formDate = {
        mainType: "B",
        orgid: "",
        pageNo: 1,
        pageSize: 10
      };
    },

    // 重置供应商参数
    resetSupplierParams(str) {
      this[str].formDate = {
        ...this[str].formDate,
        pageNo: 1,
        pageSize: 10
      };
    },
    // 供应商设置 end

    // 项目名称设置 start

    // 获取项目名称数据
    getProjectNameData(
      fillOrg,
      contractOrderOrg,
      defaultParams = this.projectObj.formDate
    ) {
      // const data = Object.assign(defaultParams, { fillOrg,contractOrderOrg });
      const data = defaultParams;
      data.contractOrderOrg = "";
      data.fillOrg = "";
      qryProjectDataAll(data).then(res => {
        const tableData = res.data.data.rows;
        tableData.forEach(item => {
          item.projectAllName =
            item.zzcountryName + item.provinceName + item.zprojlocName;
        });
        this.projectObj.tableData = tableData;
        this.projectObj.recordsTotal = res.data.data.recordsTotal;
      });
    },

    // 项目名称
    selectProjectName(val) {
      console.log("选中的项目名称", val);
      if (val.status === "confirm") {
        const {
          confirmSelect,
          confirmSelect: {
            zprojtypeName,
            zprojname,
            zproject,
            z2ndorg,
            zapproval,
            zapvldate,
            zcpbc,
            zfindate,
            zhereinafter,
            zstartdate,
            zproOrg,
            zprojectup,
            zprojename,
            zprojlocName,
            zprojtype,
            zprojyear,
            zstate,
            zzcountryName,
            zzcountry,
            provinceCode,
            provinceName,
            zprojloc,
            zproOrgName,
            zacorgId,
            zacorgno
          }
        } = val;

        const str = this.getType(confirmSelect);

        console.log("str:", str, "val:", val);

        if (str === "Object") {
          this.resetProjectNameParams("projectObj");
          this.form.projectCode = zproject;
          this.form.projectName = zprojname;
          this.smpProjectReqBO.projectType = zprojtypeName; // 项目类型
          this.smpProjectReqBO.projectTypeCode = zprojtype; // 项目类型编码
          this.smpProjectReqBO.projectCode = zproject; // 项目编号
          this.smpProjectReqBO.projectSuperiorCode = zprojectup; // 项目上级编码
          this.smpProjectReqBO.projectName = zprojname; // 项目名称
          this.smpProjectReqBO.projectForeignName = zprojename; // 项目外文名称
          this.smpProjectReqBO.projectAbbreviation = zhereinafter; // 项目简称
          this.smpProjectReqBO.countryCode = zzcountry; // 国家编码
          this.smpProjectReqBO.country = zzcountryName; // 国家/地区
          this.smpProjectReqBO.provinceCode = provinceCode; // 省编码
          this.smpProjectReqBO.province = provinceName; // 省
          this.smpProjectReqBO.cityCode = zprojloc; // 市编码
          this.smpProjectReqBO.city = zprojlocName; // 市
          this.smpProjectReqBO.projectLocation = zprojlocName; // 项目所在地
          this.smpProjectReqBO.businessTypeZj = zcpbc; // 中交行业业务类型
          this.smpProjectReqBO.approvalNo = zapproval; // 项目批复/决议号
          this.smpProjectReqBO.approvalDate = zapvldate
            ? Date.parse(zapvldate)
            : ""; // 项目批复/决议时间
          this.smpProjectReqBO.projectOrgan = zproOrgName; // 项目机构名称
          this.smpProjectReqBO.projectOrganId = zproOrg; // 项目机构
          this.smpProjectReqBO.projectYear = zprojyear; // 项目年份
          this.smpProjectReqBO.planStartDate = zstartdate
            ? Date.parse(zstartdate)
            : ""; // 项目计划开始日期
          this.smpProjectReqBO.planEndDate = zfindate
            ? Date.parse(zfindate)
            : ""; // 项目计划完成日期
          this.smpProjectReqBO.secondLevelOrgan = z2ndorg; // 所属二级单位
          this.smpProjectReqBO.state = zstate; // 状态
          this.smpProjectReqBO.accountingOrganId = zacorgId; // 核算组织id
          this.smpProjectReqBO.accountingOrganCode = zacorgno; // 核算组织编码
        }
        this.selectProjectNameReset();
      } else {
        this[this.getSelectProjectNameStrategy[val.status]](val);
        if (["closeReset"].includes(val.status)) return; // 点击叉号只清空数据，不调接口
        this.getProjectNameData(
          this.form.reportInOrgId,
          this.form.partyAId,
          this.projectObj.formDate
        );
      }
    },

    // 项目查询
    selectProjectNameSearch(val) {
      this.projectObj.formDate = val.formDate;
      this.projectObj.formDate.pageNo = 1;
    },

    // 当前页条数
    selectProjectNamePageSize(val) {
      this.projectObj.formDate.pageSize = val.pageSize;
    },

    // 页码
    selectProjectNamePageNo(val) {
      this.projectObj.formDate.pageNo = val.pageNo;
    },

    // 项目名称重置
    selectProjectNameReset(val) {
      this.projectObj.formDate = {
        fillOrg: "",
        contractOrderOrg: "",
        pageNo: 1,
        pageSize: 10
      };
    },

    // 重置项目名称参数
    resetProjectNameParams(str) {
      this.projectObj.formDate = {
        ...this.projectObj.formDate,
        pageNo: 1,
        pageSize: 10
      };
    },

    // 项目名称设置 end

    // 框架协议参照选择
    confirmSelect(val) {
      if (val.length) {
        this.initIsOverseas = this.form.isOverseas;
        this.initCurrencyCode = this.form.currencyCode;
        this.initCurrencyName = this.form.currencyName;
        this.initProtocalCode = this.form.protocalCode;
        this.initProtocalId = this.form.protocalId;
        this.initProtocalName = this.form.protocalName;
        this.initProtocalParams(val);
        this.setProtocalData(val);
        this.setIsOverseas(val[0].isOverseas);
        this.setCurrencyObj({
          code: val[0].currencyCode,
          name: val[0].currencyName
        });
        this.setDelectList(false);
        this.$nextTick(() => {
          if (this.getPurchaseListStatus) {
            this.agreementSelectTableList = val;
          }

          // 设置清单列表中的采购计划选择状态
          this.setAgreementSelectStatus(!!this.form.protocalCode);
        });
      }
    },

    // 选择协议重置是否海外采购、币种、兑换人民币汇率，对方联系人，对方手机
    initProtocalParams([protocalParams]) {
      if (protocalParams?.isShow !== null) {
        this.form.isShow = protocalParams.isShow;
      }
      // 是否海外采购
      // this.form.isOverseas =
      //   protocalParams.isOverseas || protocalParams.isOverseas === 0
      //     ? protocalParams.isOverseas
      //     : 3;
      // 币种
      // this.form.currencyName = protocalParams.currencyName || "人民币";
      // 兑换人民币汇率
      this.form.chExchangeRate = protocalParams.chExchangeRate
        ? protocalParams.chExchangeRate.toFixed(4)
        : this.form.chExchangeRate;
      // 对方联系人
      this.form.contractPerson =
        protocalParams.contractPerson || this.form.contractPerson;
      // 对方手机
      this.form.contractPersonTel =
        protocalParams.contractPersonTel || this.form.contractPersonTel;

      // 初始化币种
      this.beforeCurrencyName = protocalParams.currencyName || "人民币";
      this.beforeCurrencyCode = protocalParams.currencyCode || "1";
      this.form.currencyCode = protocalParams.currencyCode || "1";
    },

    // 提交表单验证
    handleSubmit() {
      return new Promise((resolve, reject) => {
        this.$refs["form"].validate(valid => {
          if (!valid) return reject("first");
          if (
            this.getInputRule(this.form.initTotalContractPriceIncludeTax) &&
            this.getInputRule(this.form.initTotalConractPriceExcludeTax)
          ) {
            resolve(this.form);
          } else {
            reject("third");
            return this.$showErrorMessage(
              "采购清单中含税单价不符合规范，请重新编辑"
            );
          }
        });
      });
    },

    // 暂存提交验证
    beforeSubmitTemp() {
      return new Promise((resolve, reject) => {
        if (
          this.getInputRule(this.form.initTotalContractPriceIncludeTax) &&
          this.getInputRule(this.form.initTotalConractPriceExcludeTax)
        ) {
          resolve(this.form);
        } else {
          reject("third");
          return this.$showErrorMessage(
            "采购清单中含税单价不符合规范，请重新编辑"
          );
        }
      });
    },

    // 多税率 change
    multiRateCodeChange(val) {
      this.$confirm("请注意，变更税率方式将会清空采购清单数量", "提示", {
        distinguishCancelAndClose: true,
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        customClass: "ccui-message-box-custom",
        closeOnClickModal: false
      })
        .then(() => {
          this.setMultiRateCode(val === 0 ? true : false);
          this.form.taxRatePercent = "";
          this.setTaxRate(0);
        })
        .catch(error => {
          this.form.multiRateCode = this.form.multiRateCode === 1 ? 0 : 1;
        });
    },

    // 海外采购 change
    isOverseasChange(val) {
      this.setIsOverseas(val);
      if (val !== 3) {
        this.$refs["form"].clearValidate(["contractPersonTel"]);
      }
    },

    handleTrim(str) {
      this.form[str] = this.form[str].trim();
      // this.form[str] = this.form[str].replace(/(^\s*)|(\s*)$/g, "");
    },

    handleCurrencyChange(val) {
      const reg = /(^(\d{0,21})\.(\d{0,4})$)|(^\d{0,26}$)/;
      this.form[val] = Number(this.form[val]).toFixed(4);
      if (!reg.test(this.form[val])) {
        this.$showErrorMessage("请输入正确的税率");
        this.form[val] = "";
      }
    },

    getType(obj) {
      return Object.prototype.toString
        .call(obj)
        .replace(/^\[object (\S+)\]$/, "$1");
    },

    getInputRule(val) {
      const reg = /(^(\d{0,11})\.(\d{0,8})$)|(^\d{0,20}$)/;
      return reg.test(val);
    },

    listProtocolinfoPage,
    queryMemberGroup,
    getQryTree,
    ...mapActions([
      "setMultiRateCode",
      "setTaxRate",
      "setSupplierData",
      "setSupplierBData",
      "setProtocalData",
      "setOrgId",
      "setTaxRateObj",
      "setDelectList",
      "setRangeList",
      "setShowDoubleTable",
      "setAgreementSelectStatus",
      "setIsOverseas", // 是否海外采购
      "setRemoveInventoryList", // 清空除物料目录的所有清单列表
      "setRemoveInventoryListStatus", // 选择协议状态
      "setProtocalCode",
      "setCurrencyObj", // 币种
      // "setRemovePartyB",
      "setRemoveSupplier",
      "setRemoveSupplierB"
    ])
  },
  computed: {
    ...mapState(["contractDraft"]),
    ...mapGetters([
      "getContractPriceIncludeTax",
      "getContractPriceExcludeTax",
      "getEchoProtocalData",
      "getPurchaseListStatus",
      "getOrgId",
      "getProtocalObj", // 协议数据
      "getSelectPartyBStrategy", // 供应商操作
      "getSelectProjectNameStrategy" // 项目名称操作
    ])
  },
  watch: {
    contractDraft: {
      deep: true,
      handler(newVal) {
        const {
          orgId,
          echoProtocalData,
          removeInventoryListStatus
          // purchaseListStatus
        } = newVal;

        this.supplierObj1.formDate.orgid = orgId;
        this.supplierObj2.formDate.orgid = orgId;
        this.projectObj.formDate.fillOrg = orgId;
        this.optionalParams = {
          ...this.optionalParams,
          reportInOrgId: orgId
        };

        this.agreementSelectTableList = echoProtocalData;

        // 清除协议编号
        if (removeInventoryListStatus) {
          this.form.protocalCode = "";
          this.form.protocalId = "";
          this.form.protocalName = "";
          this.setRemoveInventoryListStatus(false);
        }
      }
    },
    getPurchaseListStatus(newVal) {
      if (!newVal) {
        this.form.isOverseas = this.initIsOverseas;
        this.form.currencyCode = this.initCurrencyCode;
        this.form.currencyName = this.initCurrencyName;
        this.form.protocalCode = this.initProtocalCode;
        this.form.protocalId = this.initProtocalId;
        this.form.protocalName = this.initProtocalName;
      }
    },
    "Enum.materialSourceList"(newVal) {
      if (newVal.length === 4) {
        newVal.pop();
        this.Enum.materialSourceList = newVal;
      }
    },
    "form.protocalCode": {
      immediate: true,
      handler(newVal) {
        this.beforeProtocalCode = newVal;
        this.setProtocalCode({ ...this.getProtocalObj, protocalCode: newVal });
      }
    },
    "form.protocalId": {
      immediate: true,
      handler(newVal) {
        this.beforeProtocalId = newVal;
        this.setProtocalCode({ ...this.getProtocalObj, protocalId: newVal });
      }
    },
    "form.protocalName": {
      immediate: true,
      handler(newVal) {
        this.beforeProtocalName = newVal;
        this.setProtocalCode({ ...this.getProtocalObj, protocalName: newVal });
      }
    },
    "form.isOverseas": {
      immediate: true,
      handler(newVal) {
        this.beforeIsOverseas = newVal;
        this.setProtocalCode({ ...this.getProtocalObj, isOverseas: newVal });
      }
    },
    "form.currencyName": {
      immediate: true,
      handler(newVal) {
        this.beforeCurrencyName = newVal;
        this.setProtocalCode({ ...this.getProtocalObj, currencyName: newVal });
      }
    },
    "form.currencyCode": {
      immediate: true,
      handler(newVal) {
        this.beforeCurrencyCode = newVal;
        this.setProtocalCode({ ...this.getProtocalObj, currencyCode: newVal });
      }
    },
    getProtocalObj(newVal) {
      this.form.isOverseas = newVal.isOverseas;
      this.form.currencyName = newVal.currencyName || "人民币";
      this.form.protocalCode = newVal.protocalCode;
      this.form.protocalId = newVal.protocalId;
      this.form.protocalName = newVal.protocalName;
      this.setProtocalCode(newVal);
    }
  }
};
</script>

<style scoped lang="scss">
.afterCurSettlePayAmtIncludeTax {
  position: absolute;
  top: -25px;
  left: 15px;
  color: #d8d8d8;
}
/deep/ .el-input {
  width: 260px;
}

/deep/ .el-button--single-number {
  width: 46px;
  margin-left: 10px;
  padding: 0 9px;
}
/deep/.ccui-pre-form-item {
  .el-form-item__label {
    line-height: 16px;
  }
}
.optionLeaf {
  padding-left: 20px;
}
</style>
